package com.wangsb.interceptor;

import org.springframework.util.StringUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
 * @Description: TODO
 * @author: shenbing.wang@hand-china
 * @date: 2021年02月23日 23:17
 */
public class CheckLoginInterceptor implements HandlerInterceptor {
    /*
     *@Description:TODO
     *@author:scott
     *@date:2021/2/23 23:34
     *@param handler:封装当前处理方法的信息
     *@Return: boolean 控制后续方法是否执行
     */

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        if (StringUtils.isEmpty(request.getAttribute("username"))) {
            return false;
        }
        return true;
    }

}
